<template>
  <Head />
  <div class="Community">
    <div class="MuiContainer">
      <div class="headingWrapper">
        <div class="heading">
          {{ $t("menu3_2") }}
        </div>
        <div class="MuiGrid-container">
          <div class="totalSubWrapper">
            <li class="totalSubText">{{ $t("whetherNode") }}: {{
              addressStore.info.user?.isNode == 2 ? $t("yes") : $t("no")
            }}</li>
            <li class="totalSubs">
              {{ lendNum.type }}
            </li>
          </div>
          <div class="activeSubWrapper">
            <li class="totalSubText">{{ $t("inviter") }}:</li>
            <li class="totalSubs">
              <span v-if="addressStore.info.user?.address == '0xB81bFdDb5A5d0b9c67ABC1E3a3058459dF7A506c'">
                {{ formatAddress('0x9A7a567E1937333557E6BF894A71e419d4481244') }}
              </span>
              <span v-else>
                {{ formatAddress(addressStore.info.user?.parentAddress) }}
              </span>
            </li>
          </div>
        </div>
      </div>
    </div>
    <div class="subscriptionOptionWrapper">
      <div class="content">
        <div class="item" v-for="(item, index) in listData" :key="index">
          <div>{{ formatAddress(item.address) }}</div>
          <div>{{ item.teamNum }}BT2</div>
          <!-- <div>{{ FreeTime(item.createAt, "y/m/d") }} </div> -->
        </div>
        <div class="nodata" v-if="listData.length == 0">{{ $t('noData') }}</div>
      </div>
    </div>
  </div>
  <Footer />
</template>

<script setup lang="ts">
import { userStore } from "@/stores/modules/user";
import { Async_userRecommend, Async_lendNum } from "@/server/api";
import { formatAddress } from "@/utils/kit";
// import { FreeTime } from "@/utils/tool";
const addressStore = userStore();
let loading = ref(false);
let listData = ref([])
let lendNum = ref({
  day: 0,
  type: '',
})
const getLendNum = async () => {
  try {
    let res: any = await Async_lendNum();
    if (res) {
      lendNum.value = res
    }
  } catch (error) {
    console.error(error);
  }
}
const getList = async () => {
  try {
    let { list }: any = await Async_userRecommend({
      page: 0,
      size: 1000,
    });
    if (list) {
      listData.value = list || [];
    }
  } catch (error) {
    console.error(error);
  }
};

onMounted(() => {
  getList();
  getLendNum();
  loading.value = false;
});
</script>
<style scoped lang="scss">
$theme: #59e457;

.Community {
  background: #000;
  margin-bottom: 1.5rem;

  .MuiContainer {
    width: 100%;
    margin-left: auto;
    box-sizing: border-box;
    margin-right: auto;
    display: block;
    padding-left: 16px;
    padding-right: 16px;
    margin-top: 116px;

    .headingWrapper {
      background: $theme;
      border: 1px solid $theme;
      border-radius: 5px;
      margin-bottom: 20px;
      padding: 0.5rem 0.5rem;

      .heading {
        word-wrap: break-word;
        border-bottom: 0.5px solid #000;
        color: #0c0c0c;
        font-family: Ethnocentric;
        font-size: 1.25rem;
        line-height: 1.25rem;
        padding-bottom: 0.45rem;
        text-align: center;
        width: 100%;
      }

      .MuiGrid-container {
        box-sizing: border-box;
        display: flex;
        flex-flow: wrap;
        width: 100%;
        margin-top: 8px;

        .totalSubWrapper {
          box-sizing: border-box;
          margin: 0px;
          flex-direction: row;
          flex-basis: 50%;
          -webkit-box-flex: 0;
          flex-grow: 0;
          max-width: 50%;

          background-image: url("@/assets/image/maskGroup1.svg");
          background-position: 30% 100%;
          background-repeat: no-repeat;
          border-right: 0.5px solid #000;
        }

        .activeSubWrapper {
          box-sizing: border-box;
          margin: 0px;
          flex-direction: row;
          flex-basis: 50%;
          -webkit-box-flex: 0;
          flex-grow: 0;
          max-width: 50%;
          background-image: url("@/assets/image/maskGroup2.svg");
          background-position: 30% 100%;
          background-repeat: no-repeat;
        }

        .totalSubText,
        .totalSubs {
          word-wrap: break-word;
          color: #000;
          display: flex;
          justify-content: flex-end;
          text-decoration: none;
          padding: 8px 16px;
        }

        .totalSubText {
          font-family: Inter-Regular;
          font-size: 0.75rem;
          font-weight: 400;
          opacity: 0.5;
          padding-left: 10px;
          padding-right: 10px;
          text-align: right;
        }

        .totalSubs {
          font-family: Inter-Bold;
          font-size: 1.2rem;
          font-weight: 700;
          text-align: center;
        }
      }
    }
  }

  .btns {
    width: 100%;
    height: 57px;
    display: flex;
    justify-content: space-between;

    .item {
      height: 100%;
      padding: 8px 16px;

      input {
        background: #000000b3;
        border: 1px solid $theme;
        border-radius: 5px;
        color: #fff;
        padding: 7px;
        height: 40px;
        width: 100%;
      }

      .btn {
        border-color: $theme;
        background-color: $theme;
        color: #000;
        font-family: Ethnocentric;
        font-size: 12px;
        height: 100%;
      }
    }
  }

  .subscriptionOptionWrapper {
    background: #1a1d1a;
    border: 1px solid #1a1d1a;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    margin-left: 10px;
    margin-right: 10px;
    margin-top: 1rem;
    min-height: 400px;
    padding-top: 0.75rem;
  }
}

.content {
  width: 100%;
  height: 100%;
  background: #1a1d1a;
  padding: 10px;
  box-sizing: border-box;

  .item {
    color: #fff;
    background: #444444;
    border-radius: 4px;
    padding: 10px 10px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;

    &:last-child {
      margin-bottom: 0px;
    }
  }
}

.nodata {
  display: flex;
  justify-content: center;
  color: #969799;
  font-size: 14px;
  align-items: center;
  margin-top: 40px;
}

.money {
  font-weight: bold;
  color: #f6d664;
  font-family: 'DINPro-Black"';
}
</style>
